<?php

namespace App\Admin\Forms\Settings;

use Encore\Admin\Widgets\Form;
use Illuminate\Http\Request;

class Develop extends Form
{
    /**
     * The form title.
     *
     * @var string
     */
    public $title = '开发';

    /**
     * Handle the form request.
     *
     * @param Request $request
     *
     * @return \Illuminate\Http\RedirectResponse
     */
    public function handle(Request $request)
    {
        dd($request->all());

        admin_success('Processed successfully.');

        return back();
    }

    /**
     * Build a form here.
     */
    public function form()
    {
        $states = [
            'on'  => ['value' => 1, 'text' => '打开', 'color' => 'success'],
            'off' => ['value' => 0, 'text' => '关闭', 'color' => 'danger'],
        ];

        $this->radio('dev.mode', '开发模式')->options([0 => '关闭', 1 => '开启'])->stacked();
        $this->radio('dev.show_trace', '显示页面Trace')->options([0 => '否', 1 => '是'])->stacked();
        $this->switch('dev.site_enable', '站点开关')->states($states)
            ->required()->help('站点关闭后将不能访问，后台可正常登录');
        $this->textarea('dev.site_disable_reason', '关站原因');
    }

    /**
     * The data of the form.
     *
     * @return array $data
     */
    public function data()
    {
        return [
            'dev' => [
                'mode'   => 1,
                'site_enable' => 0,
                'show_trace' => 1,

                'site_disable_reason' => '维护需要'
            ]

        ];
    }
}
